const API_BASE_URL = 'https://your-api-endpoint.com';
export async function submitBooking(data) {
    return fetch("/api/book", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
    }).then(res => res.json());
}

export const ApiService = {
    // 获取酒店列表
    async getHotels(params) {
        const query = new URLSearchParams(params).toString();
        const response = await fetch(`${API_BASE_URL}/hotels?${query}`);
        return await response.json();
    },

    // 获取热门目的地
    async getPopularDestinations() {
        const response = await fetch(`${API_BASE_URL}/destinations/popular`);
        return await response.json();
    },

    // 用户登录
    async login(credentials) {
        const response = await fetch(`${API_BASE_URL}/auth/login`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(credentials)
        });
        return await response.json();
    },

    // 获取用户信息
    async getUserInfo(token) {
        const response = await fetch(`${API_BASE_URL}/user`, {
            headers: {
                'Authorization': `Bearer ${token}`
            }
        });
        return await response.json();
    }


}

